<?php

require_once 'phpmoko/ui/Widget.php';
require_once 'phpmoko/ui/DeckPanel.php';
require_once 'phpmoko/ui/TabBar.php';

class TabPanel extends Widget
{
	private $deckPanel;
	private $tabBar;
	private $vPanel;

	function TabPanel()
	{
		parent::__construct();

		$this->tabBar = new TabBar();

		$this->deckPanel = new DeckPanel();
		$this->deckPanel->setStyleName('pmk-TabPanelBottom');

		$this->vPanel = new VerticalPanel();
		$this->vPanel->add($this->tabBar);
		$this->vPanel->add($this->deckPanel);
		$this->vPanel->setStyleName('pmk-TabPanel');
	}

	function setAnimationEnabled($enable)
	{
		$this->deckPanel->setAnimationEnabled($enable);
	}

	function selectTab($index)
	{
		$this->deckPanel->showWidget($index);
		$this->tabBar->selectTab($index);
	}

	/**
	 * @param Widget $widget
	 * @param string $title
	 */
	function add($widget, $tabText)
	{
		$this->deckPanel->add($widget);
		$this->tabBar->addTab($tabText);
	}

	/**
	 * (non-PHPdoc)
	 * @see phpmoko/ui/Widget#setId($id)
	 */
	function setId($id)
	{
		parent::setId($id);
		$this->vPanel->setId($this->id);
		$this->tabBar->setId($this->id);
		$this->deckPanel->setId($this->id);
	}

	/**
	 * (non-PHPdoc)
	 * @see phpmoko/ui/Widget#setWidth($width)
	 */
	function setWidth($width)
	{
		parent::setWidth($width);
		$this->vPanel->setWidth($width);
	}

	/**
	 * (non-PHPdoc)
	 * @see phpmoko/ui/Widget#toString()
	 */
	function toString()
	{
		return $this->vPanel->toString();
	}
}
?>